package fhq.hcmute.edu.vn.language;

import fhq.hcmute.edu.vn.config.AppConfig;

/**
 * @author nglehien Nov 11, 2012 - 1:39:01 PM
 */
public class LanguageFactory {
	private static LanguageFactory instance = null;
	private Language language = null;

	public static LanguageFactory getInstance() {
		if (instance == null) {
			instance = new LanguageFactory();
		}
		return instance;
	}

	private LanguageFactory() {
		int id = AppConfig.getInstance().getLanguage();
		if (id == Language.ENGLISH) {
			language = new Language_EN();
		} else {
			language = new Language_VN();
		}
	}

	public static void setDefaultLanguage(int id) {
		AppConfig.getInstance().setLanguage(id);
		AppConfig.getInstance().commit();
		instance = new LanguageFactory();

	}

	public Language getLanguage() {
		return language;
	}
}
